#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

#include "../../src/cdslib.h"

#define cast(x) (void *)(x)
#define LENGTH 10

int main() 
{
    int i;
    Array a;
    initArray(&a, LENGTH);

    /* Testing length */
    assert(a.length == LENGTH);

    /* Testing bounds checking */
    ArrayGet(&a, 123);

    /* Testing set */
    for(i = 0; i < a.length; i++) {
        ArraySet(&a, i, cast(2*i));
    }

    /* Testing get */
    for(i = 0; i < a.length; i++) {
        printf("%d ", (int)ArrayGet(&a, i));
    }
    printf("\n");

    /* Testaing the return value of set */
    assert(ArraySet(&a, 4, cast(12)) == (void *)8);

    deleteArray(&a);

    return EXIT_SUCCESS;
}
